/** 创建组件对象 * */
var indicatorExtractionForm = new Form();
var indicatorExtractionTable = new Table();
var indicatorExtractionPage = new Page();
var indicatorExtractionDialog = new Dialog();
var indicatorExtractionAjax = new Ajax();
var array = [ "indicatorExtractionLogQueryDiv", "indicatorExtractionLogPageDiv" ];

var companyObj;

/** 页面加载完执行 * */
$(function() {
	initScript();
	initConditions();
	initDate();
	initPage();
	pageQuery();
	resetTableHeight("indicatorExtractionLogTableDiv", array);
	initElementsControl();
});

/** 初始化script * */
function initScript() {
	loadScript(appPath
			+ "/project-yddemo/indicatorDataExtraction/locale/IndicatorExtraction_"
			+ appLocale + ".js"); // 1.加载国际化js*
	loadScript(appPath
			+ "/project-yddemo/indicatorDataExtraction/properties/IndicatorExtractionLogProperties_View.js"); // 2.加载配置js(非必配,配置也可写在本js中)
	loadScript(staticPath + "/sis-common/js/TimeObjectUtil.js");
}

/** 初始化查询条件 * */
function initConditions() {
	indicatorExtractionForm.initTableConditions({
		divId : "indicatorExtractionLogQueryDiv", // 1.归属div*
		type : "table",
		conditions : IndicatorExtractionProperties_View.getViewConditions(), // 2.配置条件*
		button : { // 4.操作按钮*
			width : "80", // 占用宽度*
			align : "center", // left,center,right,百分比*
			label : indicatorExtractionLocale.text.updateData, // 文本*
			action : "yddemo:indicatorDataExtractionLog:view",// 增加页面元素控制
			clickFun : function() { // 按钮事件*
				var data = indicatorExtractionForm.getQueryConditions();
				if(companyObj!=undefined){
					data.companyId = companyObj.id;
				}
				var resultJson = indicatorExtractionAjax.sendAjax({
					url : requestPath+ "/yddemo/indicatorDataExtractionLogs", // 请求url*
					async : false, // 是否异步*
					type : "GET", // 请求类型*
					data : data 
				});
				if (resultJson.success) {
					indicatorExtractionDialog.tipDialog(indicatorExtractionLocale.text.updateDataSuccess,
							function() {
								pageQuery(); // 成功后,刷新页面
							});
				} else {
					indicatorExtractionDialog.alertDialog(resultJson.message); // 失败后,弹出警告框
				}
			}
		}
	});
	
	var companyInput = $("[key$='companyId']");
	companyInput.bind("click", function() {
		indicatorExtractionDialog.iframeDialog(requestPath
				+ "/yddemo/indicatorDataExtractions/dialog/companyDialog",
				indicatorExtractionLocale.field.company, 400, 300,
				"yddemo:indicatorDataExtractionLog:view", false);
	});
	companyInput.bind("focus",function(){
		companyInput.blur();
	});
}

function initDate() {
	$("#indicatorExtractionLogQueryDiv").find("[key *= 'Time']").jeDate({
		isinitVal : true,
		initAddVal : {
			YYYY : "0",
			MM : "0"
		},
		// 2.初始化时分秒
		ishmsVal : false,
		format : "YYYY-MM-DD",
		zIndex : 3000,
		language : getJeDateLanguage()
	});
}

/** 初始化分页 * */
function initPage() {
	indicatorExtractionPage.initPage({
		divId : "indicatorExtractionLogPageDiv", // 1.归属div*
		eachPageNum : 10, // 2.每页条数(5,10,15,20)*
		pageChangeFun : function() { // 3.分页刷新事件*
			indicatorExtractionTable.reloadData();
		}
	});
}

/** 分页查询 * */
function pageQuery() {
	indicatorExtractionTable.initTable({
		divId : "indicatorExtractionLogTableDiv", // 1.归属div*
		dataAjax : { // 2.发送ajax请求*
			url : requestPath + "/yddemo/indicatorDataExtractionLogs/findAllLog", // 请求url*
			type : "GET", // 请求类型*
			page : indicatorExtractionPage
		// 分页对象(需要分页时配置)
		},
		columns : IndicatorExtractionProperties_View.getViewColumns()// 3.表格列配置
	});
	indicatorExtractionTable.reloadData();
}

/**
 * 窗口大小改变时触发
 * 
 * @param
 * @return
 */
$(window).resize(function() {
	resetTableHeight("indicatorDataExtractionLogTableDiv", array);
});
